from selenium.webdriver.common.by import By

from demo.weworkSelenium.page.base_page import BasePage
from demo.weworkSelenium.page.contact import Contact
from demo.weworkSelenium.page.import_user import ImportUser
from demo.weworkSelenium.page.manage_tool import ManageTool
from demo.weworkSelenium.page.message import Message


class Main(BasePage):
    _base_url = 'https://work.weixin.qq.com/wework_admin/frame#index'

    def add_member(self):
        locator = (By.LINK_TEXT, '添加成员')
        # self.find(locator).click()
        self._driver.execute_script('arguments[0].click();', self.find(locator))
        return Contact(reuse=True)

    def import_user(self):
        locator = (By.LINK_TEXT, '导入通讯录')
        self.find(locator).click()
        return ImportUser(reuse=True)

    def send_message(self):
        locator = (By.LINK_TEXT, '消息群发')
        self.find(locator).click()
        return Message(reuse=True)

    def add_picture(self):
        locator = (By.LINK_TEXT, '管理工具')
        self.find(locator).click()
        return ManageTool(reuse=True)
